#
# @lc app=leetcode.cn id=268 lang=python3
#
# [268] 缺失数字
#

# @lc code=start
class Solution:
    def missingNumber(self, nums: List[int]) -> int:
        # # ?????
        # n = len(nums)
        # sum1 = n * (n + 1) // 2
        # return sum1 - sum(nums)

        # ???(XOR???????XOR???????)
        # n????????????n???
        n = len(nums)
        for i, num in enumerate(nums):
            n ^= i ^ num
        return n

# @lc code=end

